package cn.tedu._03vehicle.base.config;

import cn.tedu._03vehicle.base.interceptors.LoginCheckInterceptor;
import cn.tedu._03vehicle.base.interceptors.MyInterceptors;
import cn.tedu._03vehicle.base.interceptors.RataLimitInterceptor;
import cn.tedu._03vehicle.base.interceptors.TimeAccessInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new MyInterceptors())
//                .addPathPatterns("/v1/**");

        registry.addInterceptor(new TimeAccessInterceptor())
                .addPathPatterns("/v1/**");
        //登录状态校验拦截器
        registry.addInterceptor(new LoginCheckInterceptor())
                .addPathPatterns("/v1/vehicle/**");
        //网站限流拦截器
        registry.addInterceptor(new RataLimitInterceptor())
                .addPathPatterns("/v1/**");
    }
}
